	var vue = new Vue({
	    el: "#main",
	    data() {
	        return {
	            deleteLoading: false,
	            isDetele: false,
	            backTop: false,
	            isShow: false,
	            obj: {
	                cate_id: '',
	                keywords: '',
	                page: 1,
	                location: ''
	            },
	            placeList: [],
	            myPlaceList: [],
	            userInfo: userInfo,
	            cateIndex: -1,
	            flag: false,
	            total: '',
	            showLoading: false,
	            deteleId: ''
	        }
	    },
	    mounted() {
	        this.obj.location = localStorage.getItem("location")
	        console.log(this.obj.location)
	        this.getPlaceList()
	        this.getMyPlaceList()
	        window.addEventListener('scroll', this.onScroll, true)
	    },
	    methods: {
	        // 获取删除id，显示弹窗
	        detelePlace(id) {
	            this.isDetele = true
	            this.deteleId = id
	        },
	        // 确认删除
	        confirmDetele() {
	            this.deleteLoading = true
	            ajax({
	                url: formal + '/place/del-place',
	                type: 'POST',
	                data: {
	                    place_id: this.deteleId
	                },
	                success: (res) => {
	                    this.getMyPlaceList()
	                    this.deleteLoading = false
	                    this.isDetele = false
	                    console.log(res)
	                }
	            })
	        },
	        // 点击返回顶部
	        topclick() {
	            var s = document.documentElement.scrollTop;
	            // 定时器 每10ms执行一次
	            timer = window.setInterval(function () {
	                // 每次走50
	                s -= 50;
	                //  到顶部后清除定时器  必须清定时器  不然就死循环了
	                if (s < 0) {
	                    window.clearInterval(timer);
	                }
	                window.scrollTo(0, s);
	            }, 10);


	        },
	        // 触底刷新列表
	        onScroll(e) {
	            this.showLoading = true
	            if (this.flag === true) {
	                this.showLoading = false
	                return
	            }
	            //变量scrollTop是滚动条滚动时，距离顶部的距离
	            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
	            if (scrollTop > 200) {
	                this.backTop = true
	            } else {
	                this.backTop = false
	            }
	            //变量windowHeight是可视区的高度
	            var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
	            //变量scrollHeight是滚动条的总高度
	            var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
	            //滚动条到底部的条件
	            let page = 1
	            if (scrollHeight - (scrollTop + windowHeight) < 100) {
	                //写后台加载数据的函数
	                page = ++this.obj.page
	                this.getMyPlaceList(page)
	                console.log("距顶部" + scrollTop + "可视区高度" + windowHeight + "滚动条总高度" + scrollHeight);
	            }
	        },
	        // 列表展示
	        getMyPlaceList(page) {
	            if (page == undefined) {
	                page = 1
	                this.showLoading = false
	            }
	            if (page == 1) {
	                this.flag = false
	            }
	            this.obj.page = page
	            ajax({
	                url: formal + '/person/my-place',
	                type: 'GET',
	                data: this.obj,
	                success: (res) => {
	                    if (res.data.list.length == 0) {
	                        if (res.data.total == 0) {
	                            this.myPlaceList = []
	                        }
	                        this.total = res.data.total
	                        this.flag = true
	                    } else {
	                        if (page > 1) {
	                            this.myPlaceList = this.myPlaceList.concat(res.data.list)
	                            this.arrRemoval(this.myPlaceList)
	                            this.total = res.data.total
	                        } else {
	                            this.myPlaceList = res.data.list
	                            this.total = res.data.total
	                        }
	                    }
	                    this.isShow = false
	                    this.showLoading = false
	                }
	            })
	        },
	        // 数组去重
	        arrRemoval(arr) {
	            let obj = {}
	            this.myPlaceList = arr.reduce((preVal, curVal) => {
	                obj[curVal.id] ? "" : obj[curVal.id] = preVal.push(curVal)
	                return preVal
	            }, [])
	            console.log(this.sonPlaceList)

	        },
	        // 导出场所列表
	        exportBtn() {
	            ajax({
	                url: formal + '/person/export-my-place',
	                data: {
	                    cate_id: this.obj.cate_id,
	                    keywords: this.obj.keywords,
	                    location: this.obj.location
	                },
	                success: (res) => {
	                    if (res.status == 1) {
	                        window.location.href = formal + res.data.url
	                    } else {
	                        showErrorTip(res.message)
	                    }
	                }
	            })
	        },
	        // 获取筛选行业id
	        chooseIndustry(index, id) {
	            this.obj.page = 1
	            this.cateIndex = index
	            this.obj.cate_id = id
	        },
	        // 跳转到编辑页面
	        goPlaceEditor(id) {
	            window.location.href = "placeEditor.html?id=" + id
	        },
	        // 行业分类
	        getPlaceList() {
	            $.ajax({
	                url: formal + '/place/category',
	                type: 'GET',
	                headers: {
	                    Authorization: 'Bearer ' + getToken
	                },
	                success: (res) => {
	                    console.log(res)
	                    this.placeList = res.data.list
	                    let newItem = {}
	                    this.placeList.map(item => {
	                        newItem = item
	                        newItem.flag = false
	                    })
	                    console.log(this.placeList)
	                }
	            })
	        },
	        // 跳转到新增场所页面
	        goAddPlace() {
	            window.location.href = "addPlace.html"
	        }
	    }
	})